<template>
  <AcceptHandleHeadComponent
    ref="acceptHandleHeadRef"
    :ucolumns="ucolumns"
    :type="LableTitle.superviseDone"
    :needMoreQuery="true"
    @setColumns="setColumns"
    @onSearch="onSearch"
    @onReset="reQuery"
  >
    <!-- 其他查询条件 -->
    <div slot="more">
      <a-form layout="inline" class="accept_more_operate_moreForm">
        <a-collapse v-model="collapseKey" class="accept_more_operate_moreForm_collapse">
          <a-collapse-panel :show-arrow="false" disabled key="1" style="font-weight: bold">
            <div slot="header" class="accept_more_operate_moreForm_collapse_head">
              <a-row :gutter="48" style="width: 100%">
                <a-col @click.stop="() => {}" :md="8" :sm="24">
                  <a-form-item label="申请人：">
                    <a-input v-model="queryParam.applyname" placeholder="请输入申请人" allowClear />
                  </a-form-item>
                </a-col>
                <a-col @click.stop="() => {}" :md="8" :sm="24">
                  <a-form-item label="被申请人：">
                    <a-input v-model="queryParam.targetname" placeholder="请输入被申请人" allowClear />
                  </a-form-item>
                </a-col>
                <a-col @click.stop="() => {}" :md="8" :sm="24">
                  <a-form-item label="来源：">
                    <a-select
                      v-model="queryParam.source"
                      style="width: 220px; font-weight: normal"
                      placeholder="请选择来源"
                      allowClear
                    >
                      <a-select-option v-for="item in Tp_applysourceList" :key="item.value" :value="item.value">
                        {{ item.name }}
                      </a-select-option>
                    </a-select>
                  </a-form-item>
                </a-col>
              </a-row>
            </div>
            <a-row :gutter="48" style="width: 100%" class="accept_more_operate_moreForm_collapse_body">
              <a-col @click.stop="() => {}" :md="12" :sm="24">
                <a-form-item label="申请时间：">
                  <a-date-picker
                    v-model="queryParam.applyStartDate"
                    :style="{ width: 'calc(50% - 12px)' }"
                    placeholder="开始日期"
                    format="YYYY-MM-DD"
                    allowClear
                    @change="subtimeListen()"
                  />
                  ~
                  <a-date-picker
                    v-model="queryParam.applyEndDate"
                    :style="{ width: 'calc(50% - 12px)' }"
                    placeholder="结束日期"
                    format="YYYY-MM-DD"
                    allowClear
                    @change="subtimeListen()"
                  />
                </a-form-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
        </a-collapse>
      </a-form>
    </div>

    <template slot="content">
      <!-- 表格数据 -->
      <div class="accept_content_table">
        <a-table
          :scroll="{ x: 1000, y: 550 }"
          :columns="ucolumns"
          :data-source="listData"
          :pagination="upagination"
          :loading="loading"
          rowKey="taskid"
          @change="tableChange"
          size="middle"
          :bordered="ubordered"
          :rowClassName="rowClassName"
          :components="header"
          ref="table"
          :key="tableCountKey"
        >
          <span slot="serial" slot-scope="text, record, index">
            {{ (upagination.current - 1) * upagination.pageSize + parseInt(index) + 1 }}
          </span>

          <div slot="starttimeSlot" slot-scope="starttime" class="beyond_hiding" style="width: 100%">
            {{ starttime | getTimeFormat('YYYY年M月D日') }}
          </div>

          <div slot="finishtimeSlot" slot-scope="finishtime" class="beyond_hiding" style="width: 100%">
            {{ finishtime | getTimeFormat('YYYY年M月D日') }}
          </div>

          <div slot="replyBackSlot" slot-scope="text, record" class="overBox" style="width: 100%">
            <a-tooltip placement="topLeft">
              <template slot="title">
                <span>{{ record.replyBack }}</span>
              </template>
              {{ record.replyBack }}
            </a-tooltip>
          </div>

          <div slot="applynameSlot" slot-scope="applyname" class="overBox" style="width: 100%">
            <a-tooltip placement="topLeft">
              <template slot="title">
                <span>{{ applyname }}</span>
              </template>
              {{ applyname }}
            </a-tooltip>
          </div>

          <div slot="targetnameSlot" slot-scope="text, record" class="beyond_hiding" style="width: 100%">
            <a-tooltip placement="topLeft">
              <template slot="title">
                <span>{{ record.targetname_bz || record.targetname_bs }}</span>
              </template>
              {{ record.targetname_bz || record.targetname_bs }}
            </a-tooltip>
          </div>

          <template slot="operation" slot-scope="text, record">
            <a href="javascript:;" @click="showHand(record, '4')">详情</a>
          </template>
        </a-table>
      </div>
    </template>
  </AcceptHandleHeadComponent>
</template>

<script>
import { queryMf_MyTaskDoneList } from '@/api/workflow/mf_MyTaskDone'
import drag from '@/components/TableDrag/drag'
import { Tp_biztype } from '@/enumeration/Tp_biztype'
import { SuperviseCommonMinxin } from '@/views/supervise/SuperviseCommonMinxin'
const ucolumns = [
  {
    title: '序号',
    width: 50,
    key: 'index',
    align: 'center',
    fixed: 'left',
    scopedSlots: { customRender: 'serial' }
  },
  {
    title: '案号',
    dataIndex: 'acceptcode',
    key: 'acceptcode',
    width: 280,
    align: 'center',
    scopedSlots: { customRender: 'acceptcodeSlot' }
  },
  {
    title: '业务名称',
    dataIndex: 'process',
    key: 'process',
    width: 200,
    align: 'center'
  },
  {
    title: '环节',
    dataIndex: 'name',
    key: 'name',
    width: 150,
    align: 'center'
  },
  {
    title: '申请人名称',
    dataIndex: 'applyname',
    key: 'applyname',
    width: 200,
    align: 'center',
    scopedSlots: { customRender: 'applynameSlot' }
  },
  {
    title: '被申请人名称',
    dataIndex: 'targetname_text',
    key: 'targetname_text',
    width: 250,
    align: 'center',
    scopedSlots: { customRender: 'targetnameSlot' }
  },
  {
    title: '申请时间',
    dataIndex: 'starttime',
    key: 'starttime',
    width: 150,
    align: 'center',
    scopedSlots: { customRender: 'starttimeSlot' }
  },
  {
    title: '办结时间',
    dataIndex: 'finishtime',
    key: 'finishtime',
    width: 150,
    align: 'center',
    scopedSlots: { customRender: 'finishtimeSlot' }
  },
  {
    title: '来源',
    dataIndex: 'source_text',
    key: 'source_text',
    width: 150,
    align: 'center',
    scopedSlots: { customRender: 'sourceSlot' }
  },
  {
    title: '承办人',
    width: 150,
    key: 'dealName',
    dataIndex: 'dealName',
    align: 'center',
    scopedSlots: { customRender: 'dealNameSlot' }
  },
  {
    title: '录入人',
    width: 150,
    key: 'startuserid',
    dataIndex: 'startuserid',
    align: 'center'
  },
  {
    title: '操作',
    dataIndex: 'action',
    key: 'action',
    width: 220,
    fixed: 'right',
    align: 'center',
    scopedSlots: { customRender: 'operation' }
  }
]
export default {
  mixins: [SuperviseCommonMinxin],
  data () {
    return {
      ucolumns: ucolumns,
      mixins: [drag],
      Tp_biztype: Tp_biztype,
      queryParam: {
        acceptcode: '', // 案号
        applyname: '', // 申请人
        targetname: '', // 被申请人
        applyStartDate: null, // 开始时间
        applyEndDate: null, // 结束时间
        source: undefined, // 来源
        pageNumber: 1,
        pageSize: 20,
        order: 'desc',
        userid: '', // 用户id
        state: '1',
        departid: null, // 部门
        bizenum: null,
        matid: null,
        category: null,
        statusapply: []
      }
    }
  },
  created () {
    this.headerChange()
    // 待处理人员
    this.initDefaultParam()
    this.queryDoneTaskList()
  },
  methods: {
    /**
     * 初始化设置默认值
     */
    initDefaultParam () {
      this.queryParam.userid = this.currentUser.userId
      this.queryParam.bizenum = this.Tp_biztype['supervise'].value
      this.queryParam.matid = '100000_360100-000201005000-QT-002-02'
    },
    onSearch (val) {
      this.queryParam.acceptcode = val
      this.queryParam.pageNumber = 1
      this.queryParam.pageSize = 20
      this.queryDoneTaskList()
    },
    /**
     * 重置查询条件并查询数据
     */
    reQuery () {
      this.queryParam = {
        acceptcode: '', // 案号
        applyname: '', // 申请人
        targetname: '', // 被申请人
        applyStartDate: null, // 开始时间
        applyEndDate: null, // 结束时间
        source: undefined, // 来源
        pageNumber: 1,
        pageSize: 20,
        order: 'desc',
        userid: '', // 用户id
        state: '1',
        departid: null, // 部门
        bizenum: null,
        matid: null,
        category: null,
        statusapply: []
      }
      this.initDefaultParam()
      this.queryDoneTaskList()
    },
    queryDoneTaskList () {
      this.queryList()
    },
    queryList () {
      const queryParam = this.getCpQueryParam()
      if (queryParam.acceptcode) {
        queryParam.acceptcode = queryParam.acceptcode.toString().trim()
      }
      if (queryParam.targetname) {
        queryParam.targetname = queryParam.targetname.toString().trim()
      }
      if (queryParam.applyname) {
        queryParam.applyname = queryParam.applyname.toString().trim()
      }
      this.loading = true
      queryMf_MyTaskDoneList(queryParam.userid, queryParam)
        .then(res => {
          if (res.code !== 0) {
            this.$message.error('获取数据失败')
          } else {
            this.listData = res.data.records
            this.upagination.total = res.data.total
            this.upagination.current = res.data.current
            this.upagination.pageSize = res.data.size
            this.needDealNum = res.data.total
            this.setEnumData(this.listData)
          }
        })
        .catch(err => {
          this.listData = []
          console.log(err, '获取数据失败')
        })
        .finally(() => {
          this.loading = false
        })
    },
    /**
     * 显示处理界面
     */
    showHand (record, pattern) {
      this.$router.push({
        path: `/SuperviseDoneOpearation/${record.taskid}/${pattern}`,
        query: {
          url: '/SuperviseDone',
          queryParam: record
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
@import '~@/components/TableDrag/style.less';
</style>

<style lang="scss" scoped>
.cursor_pointer:hover {
  color: #55a7f5;
}
.accept_content {
  &_table {
    &_font_red {
      color: #ca0000;
      font-size: 16px;
      font-family: 'PingFang-SC-Heavy';
      font-weight: 400;
    }

    ::v-deep .ant-table-row-cell-break-word {
      font-size: 16px;
      font-family: 'PingFang-SC-Heavy';
      font-weight: 400;
      color: #2c2c2c;
    }

    ::v-deep .ant-table-thead > tr > th {
      height: 50px;
    }

    ::v-deep .ant-table-row-cell-break-word {
      font-size: 16px;
      font-family: 'PingFang-SC-Heavy';
      font-weight: 600;
      color: #2c2c2c;
    }

    // ::v-deep .ant-pagination-total-text {
    //   font-size: 16px;
    //   font-family: 'PingFang-SC-Heavy';
    //   font-weight: 400;
    //   color: #8e97b9;
    // }

    ::v-deep .ant-table-body,
    .ant-table-header {
      word-break: break-all;
      &::-webkit-scrollbar {
        width: 10px; /*高宽分别对应横竖滚动条的尺寸*/
        // height: 10px;
      }
      &::-webkit-scrollbar-thumb {
        border-radius: 6px;
        // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        background: #a2c6e1;
      }
      &::-webkit-scrollbar-track {
        // -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
        border-radius: 5px;
        background: transparent;
      }
    }
  }
}
</style>
